CC=gcc
PY=python3
TAR=silly

compile:
	$(CC) -g -fno-stack-protector -z execstack silly2.c -D_FORTIFY_SOURCE=0 -o $(TAR)
	$(CC) -m64 -c -o shellcode.o shellcode.S
	objcopy -S -O binary -j .text shellcode.o shellcode.bin

exploit: compile
	$(PY) exploit.py | env - setarch -R ./$(TAR)

run: compile
	env - setarch -R $(TAR)

gdb:
	echo $$(pgrep a.out | tail -n 1)
	gdb -p $$(pgrep a.out | tail -n 1) -x .gdb_init

simple:
	gcc silly.c

clean:
	@rm a.out *.o *.bin $(TAR)
